<%--
  Created by IntelliJ IDEA.
  User: Albert Lee
  Date: 2020/5/25
  Time: 9:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" import="java.sql.*"%>
<%
    request.setCharacterEncoding("utf-8");
    String name = request.getParameter("name");
    String pwd = request.getParameter("pwd");
    Class.forName("com.mysql.cj.jdbc.Driver");
//桥接
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/demo","r oot","123456");
//连接数据库
    String sql = "insert into user values(null,?, ?)";

    PreparedStatement ps = con.prepareStatement(sql);
    ps.setString(1,name);
    ps.setString(2,pwd);
    ps.executeUpdate();
    con.close();
    response.sendRedirect("adduser.jsp");
%>
